package com.mmz.test.socket;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Server {

	public static void main(String[] args) {
		try {
			ServerSocket serverSocket = new ServerSocket(8080);
			ExecutorService pool = Executors.newCachedThreadPool();
			int count=0;
			while(true){
				Socket socket = serverSocket.accept();
				pool.execute(new SocketThread(socket));
				
				count++;
				
				System.out.println("当前有"+count+"个客户端");
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
